package LeetCode;

import java.util.LinkedList;
import java.util.Queue;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}16:15
 */
public class LeetCode860 {
    public static void main(String[] args) {
        int[] arr = {5,5,5,10,20};
        System.out.println(new LeetCode860().lemonadeChange(arr));
    }

    public boolean lemonadeChange(int[] bills) {
       int five = 0;
       int ten = 0;
        for (int bill : bills) {
            if (bill == 5){
                five++;
            }else if (bill == 10){
                if (five > 0){
                    five--;
                    ten++;
                }else {
                    return false;
                }
            }else {
                if (five > 0 && ten >0){
                    five--;
                    ten--;
                }else if (five >= 3){
                    five -= 3;
                }else {
                    return false;
                }
            }
        }
        return true;
    }
}
